package com.haiyou.dc.excel;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.event.SyncReadListener;
import com.alibaba.excel.read.metadata.ReadSheet;

import java.io.InputStream;
import java.util.List;

public class ExcelUtil2 {

    public static <T> List<T> readListFrom(InputStream is, Class<T> clz) {
        SyncReadListener tmpListener = new SyncReadListener();
        ReadSheet readSheet = new ReadSheet();
        readSheet.setClazz(clz);
        EasyExcel.read(is).registerReadListener(tmpListener).build().read(readSheet);
        return (List<T>) tmpListener.getList();
    }
}
